<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./jquery-3.4.1/jquery-3.4.1.min.js"></script>
    <style>
        #small{width: 300px;height: 500px;position: absolute;left: 50px;top: 50px;}
        #small img{width: 100%;height: 100%;}
        #mark{display: none; width: 100px;height: 100px;background: white;opacity: 0.5;position: absolute;top: 0;left: 0;}
        #big{display: none; width: 400px;height: 400px;border: 1px solid black;left: 500px;top: 50px;position: absolute;overflow: hidden;}
        #big img{width: 1200px;height: 2000px;position: absolute;left: 0;top: 0;}
    </style>
    <script>
        $(function(){
            $("#small").mouseenter(function(){
                $("#mark").show();
                $("#big").show();
            }).mouseleave(function(){
                $("#mark").hide();
                $("#big").hide();
            }).mousemove(function(ev){
                let l = ev.pageX - $(this).offset().left;
                let t = ev.pageY - $(this).offset().top;
                if(l<=50)l=50;
                if(l>=250)l=250;
                if(t<50)t=50;
                if(t>450)t=450;
                //改变遮罩层的位置
                $("#mark").css({
                    left: l-50,
                    top: t-50
                })
                //放大位置
                $("#big img").css({
                    left: -4*(l-50),
                    top: -4*(t-50)
                })
            })
        })
    </script>
</head>
<body>
    <div id="small">
        <img src="../028 3D效果/img/5.jpg" alt="">
        <div id="mark"></div>
    </div>
    <div id="big">
        <img src="../028 3D效果/img/5.jpg" alt="">
    </div>
</body>
</html>